package net.bxx2004.cp.commands;

import net.bxx2004.cp.commands.subs.*;
import net.bxx2004.pandalib.pcommands.PCommand;
import net.bxx2004.pandalib.pcommands.PSubcommands;
import net.bxx2004.pandalib.planguage.PHelper;
import net.bxx2004.pandalib.planguage.PMessage;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.List;

public class MainCommand extends PCommand {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if (strings.length < 1){
            Player player = (Player) commandSender;
            if (player.hasPermission("cp.use")){
                PHelper helper = PCommand.getCommandHelp(this,null);
                helper.toPlayerOfKey(player,"CloudPlugin",false);
            }else {
                PMessage.to(player,"&c你没有权限...");
            }
        }
        return super.onCommand(commandSender, command, s, strings);
    }

    @Override
    public String getName_Per_Allies() {
        return "CloudPlugin-cp.use-CP";
    }

    @Override
    public List<PSubcommands> doCommand() {
        List<PSubcommands> list = new ArrayList<>();
        list.add(new EnablePluginCommand());
        list.add(new DisEnablePluginCommand());
        list.add(new InfoPluginCommand());
        list.add(new ListPluginCommand());
        list.add(new DownLoadPluginCommand());
        return list;
    }

    @Override
    public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
        List list = new ArrayList();
        list.add("enable");
        list.add("disenable");
        list.add("list");
        list.add("info");
        list.add("download");
        return list;
    }
}
